﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
using BackupLib;

namespace BackupSvc
{
    public partial class BackupSvc : ServiceBase
    {
        public BackupSvc()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            Start();
        }

        protected override void OnStop()
        {
        }

        private void Start()
        {
            InitIPC();
        }

        internal void InitIPC()
        {
            //Instantiate our server channel.
            IpcServerChannel channel = new IpcServerChannel("ServerChannel");

            //Register the server channel.
            ChannelServices.RegisterChannel(channel, true);

            //Register this service type.
            RemotingConfiguration.RegisterWellKnownServiceType(
                                        typeof(ServerMethods),
                                        "ServerMethods",
                                        WellKnownObjectMode.Singleton);
        }
    }
}
